package com.demo.highSpeedMap.controller;

import com.demo.highSpeedMap.entity.DoorDrivingInfo;
import com.demo.highSpeedMap.service.DoorDrivingInfoService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping(path = {"/doorDrivingInfo"})
public class DoorDrivingInfoController {

    @Autowired
    DoorDrivingInfoService doorDrivingInfoService;

    @RequestMapping(path = {"/queryDoorDrivingInfo"})
    @ResponseBody
    public List<DoorDrivingInfo> queryDoorDrivingInfo (HttpServletRequest request){
        List<DoorDrivingInfo> list = doorDrivingInfoService.queryDoorDrivingInfo();
        return list;
    }

    @RequestMapping(path = {"/queryByDoorId"})
    @ResponseBody
    public String  queryByDoorId(@RequestParam String doorId){
        DoorDrivingInfo drivingInfo = doorDrivingInfoService.queryByDoorId(doorId);
        StringBuilder strB = new StringBuilder();
        if (drivingInfo != null){
            strB.append("doorId:").append(drivingInfo.getDoorId()).append("\r\n")
                    .append("经度:").append(drivingInfo.getLongitude()).append("\r\n")
                    .append("纬度:").append(drivingInfo.getLatitude());
        }

        return strB.toString();
    }





}
